#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi


#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > cc2_r12_aux_nh3_sym.info <<'%EOF%'
   cc2_r12_aux_nh3_sym
   -------------
   Molecule:         NH3 
   Wave Function:    CC2-R12 / 6-311G**
   Test Purpose:     Check CC2-R12 excitation enegies with symmetry
%EOF%

#######################################################################
#  MOLECULE INPUT
#######################################################################
cat > cc2_r12_aux_nh3_sym.mol <<'%EOF%'
BASIS
6-311G** 6-311++G(3df,3pd)
NH3: CC2-R12/Ansatz1 excitation enegies with symmetry

    4    1  Z
 1      7.    1
N          0.6023400            0.00000000              0.00000000
 1      1.    2
H         -0.1947831            0.899791                1.558484
H         -0.1947831           -1.7995826090           -0.000000
 2      7.    1
N          0.6023400            0.00000000              0.00000000
 2      1.    2
H         -0.1947831            0.899791                1.558484
H         -0.1947831           -1.7995826090           -0.000000

%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > cc2_r12_aux_nh3_sym.dal <<'%EOF%'
**DALTON INPUT
.RUN WAVE FUNCTION
.DIRECT
*MOLBAS
.R12AUX
**INTEGRALS
.R12
**WAVE FUNCTIONS
.CC
*ORBITAL INPUT
.MOSTART
 H1DIAG
*SCF INPUT
.THRESHOLD
 1D-10
*CC INPUT
.CC2
.PRINT
 3
.FROIMP
  1 0
  0 0
.THRENR
 1.0D-10
*CCEXCI
.THREXC
 1.D-8
.NCCEXCI
 4 4 
*R12 INPUT
#.NO HYB
#.R12XXL
#.NO B
#.NO A'
#.NO 2
.CC2
 1A
**END OF DALTON INPUT
%EOF%

#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >cc2_r12_aux_nh3_sym.check
cat >>cc2_r12_aux_nh3_sym.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

#   
#            Total SCF   energy:                   -56.2064628821
#            Total MP2-R12/A energy:               -56.4417470974
#            Total CC2-R12/A energy:               -56.4431137663
#
#
# +=============================================================================+
# |  sym. | Exci.  |        CC2-R12/A  Excitation energies            | ||T1||  |
# |(spin, |        +------------------------------------------------------------+
# | spat) |        |     Hartree    |       eV.      |     cm-1       |    %    |
# +=============================================================================+
# | ^1A'  |    1   |     0.2730761  |       7.43078  |     59933.283  |  96.28  |
# | ^1A'  |    2   |     0.3537722  |       9.62663  |     77644.025  |  96.47  |
# | ^1A'  |    3   |     0.4678022  |      12.72955  |    102670.717  |  97.03  |
# | ^1A'  |    4   |     0.5486682  |      14.93002  |    120418.755  |  97.38  |
# +-----------------------------------------------------------------------------+
# | ^1A"  |    1   |     0.3537722  |       9.62663  |     77644.031  |  96.47  |
# | ^1A"  |    2   |     0.4678023  |      12.72955  |    102670.728  |  97.01  |
# | ^1A"  |    3   |     0.5479846  |      14.91142  |    120268.718  |  97.03  |
# | ^1A"  |    4   |     0.5486682  |      14.93002  |    120418.755  |  96.97  |
# +=============================================================================+
#
#

CRIT1=`$GREP "Total MP2-R12/A energy:               -56.4417470974" $log | wc -l`
TEST[1]=`expr   $CRIT1`
CTRL[1]=2
ERROR[1]="MP2-R12/A ENERGY NOT CORRECT"
CRIT2=`$GREP "Total CC2-R12/A energy:               -56.4431137663" $log | wc -l`
TEST[2]=`expr   $CRIT2`
CTRL[2]=2
ERROR[2]="CC2-R12/A ENERGY NOT CORRECT"
#
CRIT3=`$GREP "\| \^1A'  \|    1   \|     ( |0)\.2730...  \|       7\.4307.  \|     59933\....  \|  96\.2.  \|" $log | wc -l`
TEST[3]=`expr   $CRIT3`
CTRL[3]=1
ERROR[3]="CC2-R12/A 1A' EXCITATION ENERGY NOT CORRECT"
CRIT4=`$GREP "\| \^1A'  \|    2   \|     ( |0)\.3537...  \|       9\.6266.  \|     77644\....  \|  96\.4.  \|" $log | wc -l`
TEST[4]=`expr   $CRIT4`
CTRL[4]=1
ERROR[4]="CC2-R12/A 2A' EXCITATION ENERGY NOT CORRECT"
CRIT5=`$GREP "\| \^1A'  \|    3   \|     ( |0)\.4678...  \|      12\.7295.  \|    102670\....  \|  97\.0.  \|" $log | wc -l`
TEST[5]=`expr   $CRIT5`
CTRL[5]=1
ERROR[5]="CC2-R12/A 3A1' EXCITATION ENERGY NOT CORRECT"
CRIT6=`$GREP "\| \^1A'  \|    4   \|     ( |0)\.5486...  \|      14\.9300.  \|    120418\....  \|  97\.3.  \|" $log | wc -l`
TEST[6]=`expr   $CRIT6`
CTRL[6]=1
ERROR[6]="CC2-R12/A 4A1' EXCITATION ENERGY NOT CORRECT"
CRIT7=`$GREP "\| \^1A\"  \|    1   \|     ( |0)\.3537...  \|       9\.6266.  \|     77644\....  \|  96\.4.  \|" $log | wc -l`
TEST[7]=`expr   $CRIT7`
CTRL[7]=1
ERROR[7]="CC2-R12/A 1A\" EXCITATION ENERGY NOT CORRECT"
CRIT8=`$GREP "\| \^1A\"  \|    2   \|     ( |0)\.4678...  \|      12\.7295.  \|    102670\....  \|  97\.0.  \|" $log | wc -l`
TEST[8]=`expr   $CRIT8`
CTRL[8]=1
ERROR[8]="CC2-R12/A 2A\" EXCITATION ENERGY NOT CORRECT"
CRIT9=`$GREP "\| \^1A\"  \|    3   \|     ( |0)\.5479...  \|      14\.9114.  \|    120268\....  \|  97\.0.  \|" $log | wc -l`
TEST[9]=`expr   $CRIT9`
CTRL[9]=1
ERROR[9]="CC2-R12/A 3A\" EXCITATION ENERGY NOT CORRECT"
CRIT10=`$GREP "\| \^1A\"  \|    4   \|     ( |0)\.5486...  \|      14\.9300.  \|    120418\....  \|  96\.9.  \|" $log | wc -l`
TEST[10]=`expr   $CRIT10`
CTRL[10]=1
ERROR[10]="CC2-R12/A 4A\" EXCITATION ENERGY NOT CORRECT"


PASSED=1
for i in 1 2 3 4 5 6 7 8 9 10 
do 
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done 

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM 
  exit 1
fi

%EOF%
#######################################################################
